﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine;

namespace GameBoardViewer.Animation
{
    internal class RotationBoardAnimation: Animation
    {
        protected float _startXRotation;
        protected float _finishXRotation;
        protected float _startYRotation;
        protected float _finishYRotation;

        public RotationBoardAnimation(float startXRotation, float finishXRotation, float startYRotation, float finishYRotation,
                        TimeSpan animationLength)
            : base(Position.Empty, animationLength)
        {
            _startXRotation = startXRotation;
            _finishXRotation = finishXRotation;
            _startYRotation = startYRotation;
            _finishYRotation = finishYRotation;
        }

        public override void GetRotationParameters(out float rotationX, out float rotationY)
        {
            rotationX = 0;
            rotationY = 0;

            float delta = 0;
            if (base.GetAnimationDelta(out delta) == false)
            {
                rotationX = _finishXRotation;
                rotationY = _finishYRotation;
                return;
            }

            float lengthX = _finishXRotation - _startXRotation;
            float lengthY = _finishYRotation - _startYRotation;

            rotationX = _startXRotation + lengthX * delta;
            rotationY = _startYRotation + lengthY * delta;
        }
    }
}
